﻿package com.kuanter.kuanterauto.alipay;

import java.net.URLEncoder;

import com.kuanter.kuanterauto.constants.MainConstants;

public class OrderInfoUtil {
	
	public static String getOrderInfo(String tradeNo,String subject,String subjectBody,String totalFee) {
		String strOrderInfo = "partner=" + "\"" + PartnerConfig.PARTNER + "\"";
		strOrderInfo += "&";
		strOrderInfo += "seller=" + "\"" + PartnerConfig.SELLER + "\"";
		strOrderInfo += "&";
		strOrderInfo += "out_trade_no=" + "\"" + tradeNo + "\"";
		strOrderInfo += "&";
		strOrderInfo += "subject=" + "\"" + subject
				+ "\"";
		strOrderInfo += "&"; 
		strOrderInfo += "body=" + "\"" +subjectBody + "\"";
		strOrderInfo += "&";
		strOrderInfo += "total_fee=" + "\""
				+ totalFee + "\"";
		strOrderInfo += "&";
		strOrderInfo += "notify_url=" + "\""
				+MainConstants.HOST_test +"cardRecharge/alipayClient/notifyReceiver" + "\"";
		System.err.println(strOrderInfo);
		return strOrderInfo;
//		http://113.57.196.238:8080/app/
	}
	
	public static String getNewOrderInfo(String tradeNo,String subject,String subjectBody,String totalFee) {
		StringBuilder sb = new StringBuilder();
		sb.append("partner=\"");
		sb.append(PartnerConfig.PARTNER);
		sb.append("\"&out_trade_no=\"");
		sb.append(tradeNo);
		sb.append("\"&subject=\"");
		sb.append(subject);
		sb.append("\"&body=\"");
		sb.append(subjectBody);
		sb.append("\"&total_fee=\"");
		sb.append(totalFee);
		sb.append("\"&notify_url=\"");

		// 网址需要做URL编码
//		sb.append(URLEncoder.encode(MainConstants.HOST_test +"cardRecharge/alipayClient/notifyReceiver"));
		sb.append(MainConstants.HOST_test +"cardRecharge/alipayClient/notifyReceiver2");
		sb.append("\"&service=\"mobile.securitypay.pay");
		sb.append("\"&_input_charset=\"UTF-8");
//		sb.append("\"&return_url=\"");
//		sb.append(URLEncoder.encode("http://m.alipay.com"));
//		sb.append("\"&payment_type=\"1");
		sb.append("\"&seller_id=\"");
		sb.append(PartnerConfig.SELLER);

		// 如果show_url值为空，可不传
		// sb.append("\"&show_url=\"");
//		sb.append("\"&it_b_pay=\"1m");
		sb.append("\"");
		System.err.println(sb.toString());
		return new String(sb);
	}
}